import Vue from 'vue'
import VueRouter from 'vue-router'
import LayoutView from '@/views/LayoutView.vue'
import Dashboard from '@/views/DashboardView.vue'
import UserManagement from '@/views/UserManagementView.vue'
import BookManagement from '@/views/BookManagementView.vue'
import LoginView from '@/views/Auth/LoginView.vue'
import RegisterView from '@/views/Auth/RegisterView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/',
    component: LayoutView,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: Dashboard,
        meta: { title: '首页' }
      },
      {
        path: 'user-management',
        name: 'UserManagement',
        component: UserManagement,
        meta: { title: '用户管理' }
      },
      {
        path: 'book-management',
        name: 'BookManagement',
        component: BookManagement,
        meta: { title: '图书管理' }
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView,
    meta: { title: '登录' }
  },
  {
    path: '/register',
    name: 'register',
    component: RegisterView,
    meta: { title: '注册' }
  }
]

const router = new VueRouter({
  routes
});

export default router
